inputed = str(input())
Dict = inputed.split()
def Func(a):
    mass = []
    Dict = {"zero": 0, "one": 1, "two": 2, "three": 3, "four": 4, "five": 5,
          "six": 6, "seven": 7, "eight": 8, "nine": 9}
    for i in range(len(a)):
        mass.append(Dict.get(a[i]))
    return mass
mass = Func(Dict)
if None in mass:
    print("Wrong input")
else:
    String = ""
    for i in range(len(mass)):
        String += str(mass[i])
    num = int(String)
    left = 0
    for i in range(1,num):
        c = 0
        for i1 in range(1,num):
            if i % i1 == 0:
               c+= 1
        if c == 2:
            d = i
    e = num
    right = 0
    while True:
        c = 0
        for i1 in range(1,e + 1):
            if e % i1 == 0:
                c+= 1
        if c == 2:
            right = i1
            break
        e += 1
    if right - num < num - left:
        print(right)
    elif right - num > num - left:
        print(a7)
    else:
        print(num)
